package top.revery.datasource.service;

import org.springframework.web.bind.annotation.RestController;
import top.revery.api.api.category.IChinaCity;

import top.revery.api.entity.other.BaseChinaCity;
import top.revery.datasource.util.dsource;
import java.util.List;

/**
 * <h1> ---  --- </h1>
 * Created by  revery.top jun
 * Date  2019-12-11 19:13
 */
@RestController
public class ChinaCityServiceController implements IChinaCity {
    @Override
    public List<BaseChinaCity> getList(int parentID) {
        List<BaseChinaCity> lists = dsource.chinaCityDto.findByPid(parentID);
        return lists;
    }

    @Override
    public BaseChinaCity save(BaseChinaCity baseChinaCity) {
        try{
            return dsource.chinaCityDto.save(baseChinaCity);
        }catch (Exception e){
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public Boolean del(Long id) {
        try{
            dsource.chinaCityDto.deleteById(id);
        }catch (Exception e){
            return false;
        }
        return true;
    }
}
